package core;

import acessoDados.Singleton;
import java.sql.SQLException;

import constants.ProjectConstants;

public class PessoaFactoryMethod {

    public Cliente criaPessoa(String login, String password, String bi, String nome, String email, String telefone,  int tipo) throws SQLException, ClassNotFoundException {

        switch (tipo) {

            case ProjectConstants.CLIENTE:
                ClienteFactoryMethod p = new ClienteFactoryMethod();
                p.criaCliente(login, password, bi, nome, email, telefone);
                return p;
            case ProjectConstants.TRIPULANTE:
                TripulanteFactoryMethod t = new TripulanteFactoryMethod();
                t.criaTripulante(login, password, bi, nome, email, telefone);
                return t;            
            case ProjectConstants.FUNCIONARIO:
                FuncionarioFactoryMethod f = new FuncionarioFactoryMethod();
                f.criaFuncionario(login, password, bi, nome, email, telefone);
                return f;
            case ProjectConstants.GESTOR:
                GestorFactoryMethod g = new GestorFactoryMethod();
                g.criaGestor(login, password, bi, nome, email, telefone);
                return g;
        }
        return null;
    }
}

class ClienteFactoryMethod extends Cliente {

    void criaCliente(String login, String password, String bi, String nome, String email, String telefone) throws SQLException, ClassNotFoundException {
        Singleton.getInstance().getPessoaDAO().criaPessoa(login, password, bi, nome, email, telefone, ""+ProjectConstants.CLIENTE);
    }
}

class TripulanteFactoryMethod extends Cliente {

	void criaTripulante(String login, String password, String bi, String nome, String email, String telefone) throws SQLException, ClassNotFoundException {
        Singleton.getInstance().getPessoaDAO().criaPessoa(login, password, bi, nome, email, telefone, ""+ProjectConstants.TRIPULANTE);
    }
}

class FuncionarioFactoryMethod extends Cliente {

	void criaFuncionario(String login, String password, String bi, String nome, String email, String telefone) throws SQLException, ClassNotFoundException {
        Singleton.getInstance().getPessoaDAO().criaPessoa(login, password, bi, nome, email, telefone, ""+ProjectConstants.FUNCIONARIO);
    }
}
 
class GestorFactoryMethod extends Cliente {

	void criaGestor(String login, String password, String bi, String nome, String email, String telefone) throws SQLException, ClassNotFoundException {
        Singleton.getInstance().getPessoaDAO().criaPessoa(login, password, bi, nome, email, telefone, ""+ProjectConstants.GESTOR);
    }
}
